<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use DB;

class Comcheckgroupself extends Model
{
	protected $table = 'comcheckgroupself';

    public function getCheckgroup($checkId,$categoryId,$status,$type)
    {
        $checkgroup = DB::select("
            select ckg.id,ckg.name,cckg.status from checkgroup ckg
            left join comcheckgroupself cckg on ckg.id = cckg.groupId and cckg.checkId = $checkId
            where ckg.categoryId = $categoryId
            and ckg.status = $status and ckg.type = $type order by ckg.id asc 
            ");
        return $checkgroup;
    }

    public function getCheckgroupByComcheck($checkId,$status)
    {
        $checkgroup = DB::select("
            select cckg.id,cckg.checkId,cckg.groupId,ckg.riskPoint,ckg.accidentType,cckg.lossPrediction,cckg.riskLevel,ckg.measures,ckg.emergencyMeasure,ckg.name from comcheckgroupself cckg
            left join checkgroup ckg on cckg.groupId = ckg.id where cckg.checkId = $checkId
            and cckg.status = $status and ckg.state = 1 
            ");
        return $checkgroup;
    }
}
